package pipeline;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import def.BioNLPDocument;
import def.Event;
import def.TSpan;

public class TriggerDetectionOracle extends TriggerDetection {
	@Override public ArrayList<TSpan> detectTriggers(BioNLPDocument doc) {
		ArrayList<TSpan> predictions  = new ArrayList<TSpan>();
		for (Event event: doc.events.values()){
			TSpan t = event.tspan;
			boolean found = false;
			for (TSpan ts: predictions){
				if (ts.startIdx == t.startIdx && ts.endIdx == t.endIdx){
					found = true;
					break;
				}
			}
			if (!found)
				predictions.add(event.tspan.clone());
		}
		for (TSpan ts: predictions){
			ts.tid = null;
			ts.textType = null;
		}
		Collections.sort(predictions, new Comparator<TSpan>(){
			@Override
			public int compare(TSpan o1, TSpan o2) {
				return o1.startIdx - o2.startIdx;
			}
		});
		return predictions;
	}
}
